<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    

<head>
    <meta charset="utf-8">
    <meta name="keywords" content="friend-斐波那契, Five-great的博客">
    <meta name="description" content="friend-斐波那契html {overflow-x: initial !important;}:root { –bg-color:#ffffff; –text-color:#333333; –select-text-bg-color:#">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>friend-斐波那契 | Five-great的博客</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/css/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>

</head>

<body>

<head>
<meta charset="utf-8">

<style>

#canvas1 {
 position: fixed;
 pointer-events:none;//鼠标多层响应事件
        // background: 	#ccc;
		 /*透明度*/
		 width: 100%;
        height: 100%;
     // opacity: 0;
		 overflow: auto;
		 z-index: 999;
}
.hint {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  opacity: 0;
  visibility: hidden;
  -webkit-animation: fade-in 1s ease-out 1s forwards, fade-out 1s ease-out 5s forwards;
          animation: fade-in 1s ease-out 1s forwards, fade-out 1s ease-out 5s forwards;
}
.hint > h1 {
  font-size: 32px;
  color: #fff;
}
@-webkit-keyframes fade-in {
  0% {
    opacity: 0;
    visibility: hidden;
  }
  100% {
    opacity: 1;
    visibility: visible;
  }
}
@keyframes fade-in {
  0% {
    opacity: 0;
    visibility: hidden;
  }
  100% {
    opacity: 1;
    visibility: visible;
  }
}
@-webkit-keyframes fade-out {
  0% {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}
@keyframes fade-out {
  0% {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}
</style>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>
<body>


<canvas id="canvas1" style="whdth: 100%;height: 100%"></canvas>
<!--<div class="hint" id="hint">
  <h1>Click.</h1>
</div>-->

<script>
var _createClass = function () {function defineProperties(target, props) 
{ for (var i = 0; i < props.length; i++) 
 {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) 
 descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}
 return function (Constructor, protoProps, staticProps) 
 {if (protoProps) defineProperties(Constructor.prototype, protoProps);
 if (staticProps) defineProperties(Constructor, staticProps);
 return Constructor;};}();function _classCallCheck(instance, Constructor) 
 {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}
 var getRandom = function getRandom(min, max) {
  return Math.random() * (max - min) + min;
};

var getRandomInt = function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min)) + min;
};

var getRandomColor = function getRandomColor() {
  var colors = [
  'rgba(231, 76, 60, 1)', // red
  'rgba(241, 196, 15, 1)', // yellow
  'rgba(46, 204, 113, 1)', // green
  'rgba(52, 152, 219, 1)', // blue
  'rgba(155, 89, 182, 1)' // purple
  ];

  return colors[getRandomInt(0, colors.length)];
};

// Particle//粒子模块
var
Particle = function () {

  function Particle(system, x, y) {_classCallCheck(this, Particle);
    this.system = system;
    this.universe = this.system.world.universe;
    this.x = x;
    this.y = y;
    this.color = getRandomColor();
    this.life = 1;
    this.aging = getRandom(0.990, 0.999); // 0.99, 0.999 || 0.999, 0.9999

    this.r = getRandomInt(12, 16);//初始粒子半径范围
    this.speed = getRandom(18, 18.5);//粒子爆炸速度范围
    this.velocity = [
    getRandom(-this.speed, this.speed),
    getRandom(-this.speed, this.speed)];

  }_createClass(Particle, [{ key: 'update', value: function update(

    dt) {
      this.life *= this.aging;

      if (
      this.r < 0.1 ||
      this.life === 0 ||
      this.x + this.r < 0 ||
      this.x - this.r > this.universe.width ||
      this.y + this.r < 0 ||
      this.y - this.r > this.universe.height)
      {
        this.system.removeObject(this);
      }

      this.r *= this.life;
      this.x += this.velocity[0];
      this.y += this.velocity[1];
    } }, { key: 'render', value: function render(

    ctx) {
      // Main circle //亮圈模块

      ctx.fillStyle = this.color;
      ctx.beginPath();
      ctx.arc(this.x, this.y, this.r*1.2, 0, 2 * Math.PI, false);
      ctx.fill();
      ctx.closePath();

      var r = this.color.match(/([0-9]+)/g)[0];
      var g = this.color.match(/([0-9]+)/g)[1];
      var b = this.color.match(/([0-9]+)/g)[2];

      // Gradient//梯度变化曲线

      var spread = 1.5;
      var gradient = ctx.createRadialGradient(
      this.x, this.y, this.r,
      this.x, this.y, this.r * spread);

      gradient.addColorStop(0, 'rgba(' + r + ', ' + g + ', ' + b + ', 0.5)');
      gradient.addColorStop(1, 'rgba(' + r + ', ' + g + ', ' + b + ', 0)');

      ctx.globalCompositeOperation = 'lighter';
      ctx.fillStyle = gradient;
      ctx.beginPath();
      ctx.arc(this.x, this.y, this.r * spread, 0, 2 * Math.PI, false);
      ctx.fill();
      ctx.closePath();
      ctx.globalCompositeOperation = 'source-over';

      // Aberration//偏差

      var offset = this.r * 0.5;
      var color = 'rgba(' + g + ', ' + b + ', ' + r + ', 0.5)';

      ctx.globalCompositeOperation = 'lighter';
      ctx.fillStyle = color;
      ctx.beginPath();
      ctx.arc(this.x + offset, this.y + offset, this.r, 0, 2 * Math.PI, false);
      ctx.fill();
      ctx.closePath();
      ctx.globalCompositeOperation = 'source-over';
    } }]);return Particle;}();



// Crown //水波纹圈模块
var
Crown = function () {

  function Crown(system, x, y) {_classCallCheck(this, Crown);
    this.system = system;
    this.x = x;
    this.y = y;
    this.r = getRandomInt(5, 15); // 5, 20  水波纹圈半径范围
    this.mod = 1.1;
    this.life = 0.5; //水波纹线
    this.aging = getRandom(0.830, 0.899);
    this.speed = getRandom(8, 9);
    this.color = {
      r: getRandomInt(236, 242),
      g: getRandomInt(70, 80),
      b: getRandomInt(50, 70) };


    this.angle1 = Math.PI * getRandom(0, 2);
    this.angle2 = this.angle1 + Math.PI * getRandom(0.3, 0.4);//水波纹圈完整度
  }_createClass(Crown, [{ key: 'update', value: function update(

    dt) {
      this.life *= this.aging;

      if (this.life <= 0.0001) this.system.removeObject(this);

      this.r += Math.abs(1 - this.life) * this.speed;

      this.x1 = this.x + this.r * Math.cos(this.angle1);
      this.y1 = this.y + this.r * Math.sin(this.angle1);

      this.angle3 = this.angle1 + (this.angle2 - this.angle1) / 2;
      this.x2 = this.x + this.r * this.mod * Math.cos(this.angle3);
      this.y2 = this.y + this.r * this.mod * Math.sin(this.angle3);
    } }, { key: 'render', value: function render(

    ctx) {
      var gradient = ctx.createRadialGradient(
      this.x, this.y, this.r * 0.9,
      this.x, this.y, this.r);

      gradient.addColorStop(0, 'rgba(' + this.color.r + ', ' + this.color.g + ', ' + this.color.b + ', ' + this.life + ')');
      gradient.addColorStop(1, 'rgba(' + this.color.r + ', ' + this.color.g + ', ' + this.color.b + ', ' + this.life * 0.5 + ')');

      ctx.fillStyle = gradient;
      ctx.beginPath();
      ctx.arc(this.x, this.y, this.r, this.angle1, this.angle2, false);
      ctx.quadraticCurveTo(this.x2, this.y2, this.x1, this.y1);
      ctx.fill();
      ctx.closePath();
    } }]);return Crown;}();



// Explosion //爆炸模块
var
Explosion = function () {

  function Explosion(world, x, y) {_classCallCheck(this, Explosion);
    this.world = world;
    this.x = x;
    this.y = y;
    this.objects = [];

    var particles = getRandomInt(10, 30); // 10, 30 amount of particles//爆炸 粒子数量
    var crowns = particles * getRandom(0.4, 0.5);

    while (crowns-- > 0) {this.addCrown();}
    while (particles-- > 0) {this.addParticle();}
  }_createClass(Explosion, [{ key: 'update', value: function update(

    dt) {
      this.objects.forEach(function (obj) {
        if (obj) obj.update(dt);
      });

      if (this.objects.length <= 0) {
        this.world.clearExplosion(this);
      }
    } }, { key: 'render', value: function render(

    ctx) {
      this.objects.forEach(function (obj) {
        if (obj) obj.render(ctx);
      });
    } }, { key: 'addCrown', value: function addCrown()

    {
      this.objects.push(new Crown(this, this.x, this.y));
    } }, { key: 'addParticle', value: function addParticle()

    {
      this.objects.push(new Particle(this, this.x, this.y));
    } }, { key: 'removeObject', value: function removeObject(

    obj) {
      var index = this.objects.indexOf(obj);

      if (index !== -1) {
        this.objects.splice(index, 1);
      }
    } }]);return Explosion;}();



// World 
var
ConfettiWorld = function () {function ConfettiWorld() 
{_classCallCheck(this, ConfettiWorld);}_createClass(ConfettiWorld, [{ key: 'init', value: function init()

    {
      this.objects = [];
      window.addEventListener('click', this.explode.bind(this));

      // Initial explosion //初始爆炸
      var counter = 0;
      while (counter-- > 0) {
        this.explode({
          clientX: window.event.clientX, //getRandomInt(10, this.universe.width) ,          //this.universe.width / 2,
          clientY: window.event.clientY //getRandomInt(10, 50) //this.universe.height / 2 
		  });

      }
    } }, { key: 'update', value: function update(

    dt) {
      this.objects.forEach(function (obj) {
        if (obj) obj.update(dt);
      });

      var amount = this.objects.reduce(function (sum, explosion) {
        return sum += explosion.objects.length;
      }, 0);
    } }, { key: 'render', value: function render(

    ctx) {
      this.objects.forEach(function (obj) {
        if (obj) obj.render(ctx);
      });
    } }, { key: 'explode', value: function explode(

    event) {
      var x = event.clientX;
      var y = event.clientY;

      this.objects.push(new Explosion(this, x, y));
    } }, { key: 'clearExplosion', value: function clearExplosion(

    explosion) {
      var index = this.objects.indexOf(explosion);

      if (index !== -1) {
        this.objects.splice(index, 1);
      }
    } }]);return ConfettiWorld;}();



// Time
var
Time = function () {

  function Time() {_classCallCheck(this, Time);
    this.now = 0; // current tick time
    this.prev = 0; // prev tick time
    this.elapsed = 0; // elapsed time from last tick
    this.delta = 0; // time from last update
    this.fps = 60; // desired fps
    this.step = 1 / 60; // step duration
  }_createClass(Time, [{ key: 'update', value: function update(

    time) {
      this.now = time;
      this.elapsed = (this.now - this.prev) / 1000;
      this.prev = this.now;
      this.delta += this.elapsed;
    } }, { key: 'raf', value: function raf(

    func) {
      window.requestAnimationFrame(func);
    } }, { key: 'hasFrames', value: function hasFrames()

    {
      return this.delta >= this.step;
    } }, { key: 'processFrame', value: function processFrame()

    {
      this.delta -= this.step;
    } }]);return Time;}();



// Canvas
var
Universe = function () {

  function Universe(element) {_classCallCheck(this, Universe);
    this.el = element;
    this.ctx = this.el.getContext('2d');
    this.pixelRatio = window.devicePixelRatio;
    this.time = new Time();

    this.worlds = {};
    this.world = null; // current state

    this.updateSize();
    window.addEventListener('resize', this.updateSize.bind(this));

    this.addWorld('confetti', ConfettiWorld);
    this.setWorld('confetti');

    this.start();
  }_createClass(Universe, [{ key: 'start', value: function start()

    {
      this.time.raf(this.tick.bind(this));
    } }, { key: 'tick', value: function tick(

    time) {
      this.time.update(time);

      if (this.time.hasFrames()) {
        this.update();
        this.time.processFrame();
      }

      this.render();
      this.time.raf(this.tick.bind(this));
    } }, { key: 'update', value: function update()

    {
      this.world.update(this.time.step);
    } }, { key: 'render', value: function render()

    {
      var gradient = this.ctx.createLinearGradient(0, 0, this.width, this.height);
     // gradient.addColorStop(0, '#34495e');
      //gradient.addColorStop(1, '#2c3e50');

      this.ctx.clearRect(0, 0, this.width, this.height);
      // this.ctx.fillStyle = '#2c3e50'
     // //this.ctx.fillStyle = gradient;
    // // this.ctx.fillRect(0, 0, this.width, this.height);
      this.world.render(this.ctx);
    }

    // Helpers 库
  }, { key: 'updateSize', value: function updateSize()
    {
      this.width = window.innerWidth;
      this.height = window.innerHeight;
      this.el.width = this.width * this.pixelRatio;
      this.el.height = this.height * this.pixelRatio;
      this.el.style.width = window.innerWidth + 'px';
      this.el.style.height = window.innerHeight + 'px';
      this.ctx.scale(this.pixelRatio, this.pixelRatio);
    } }, { key: 'addWorld', value: function addWorld(

    worldName, World) {
      this.worlds[worldName] = new World();
      this.worlds[worldName].universe = this;
      this.worlds[worldName].init();
    } }, { key: 'setWorld', value: function setWorld(

    worldName) {
      this.world = this.worlds[worldName];
    } }]);return Universe;}();



// Main

console.clear();
var element = document.querySelector('#canvas1');
window.Canvas= new Universe(element);</script>

</body>


<header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="container">
            <div class="nav-wrapper">
                <div class="brand-logo">
                    <a href="/" class="waves-effect waves-light">
                        
                        <img src="/medias/logo.png" class="logo-img hide-on-small-only">
                        
                        <span class="logo-span">Five-great的博客</span>
                    </a>
                </div>
                <a href="#" data-activates="mobile-nav" class="button-collapse"><i class="fa fa-navicon"></i></a>
<ul class="right">
    
    <li class="hide-on-med-and-down">
        <a href="/" class="waves-effect waves-light">
            
            <i class="fa fa-home"></i>
            
            <span>首页</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/tags" class="waves-effect waves-light">
            
            <i class="fa fa-tags"></i>
            
            <span>标签</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/categories" class="waves-effect waves-light">
            
            <i class="fa fa-bookmark"></i>
            
            <span>分类</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/archives" class="waves-effect waves-light">
            
            <i class="fa fa-archive"></i>
            
            <span>归档</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/about" class="waves-effect waves-light">
            
            <i class="fa fa-user-circle-o"></i>
            
            <span>关于</span>
        </a>
    </li>
    
    <li>
        <a id="toggleSearch" class="waves-effect waves-light">
            <i id="searchIcon" class="mdi-action-search"></i>
        </a>
    </li>

</ul>

<div class="side-nav" id="mobile-nav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">Five-great的博客</div>
        <div class="logo-desc">
            
            有事多研究 没事多琢磨
            
        </div>
    </div>

    <ul class="menu-list mobile-menu-list">
        
        <li>
            <a href="/" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-home"></i>
                
                首页
            </a>
        </li>
        
        <li>
            <a href="/tags" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-tags"></i>
                
                标签
            </a>
        </li>
        
        <li>
            <a href="/categories" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-bookmark"></i>
                
                分类
            </a>
        </li>
        
        <li>
            <a href="/archives" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-archive"></i>
                
                归档
            </a>
        </li>
        
        <li>
            <a href="/about" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-user-circle-o"></i>
                
                关于
            </a>
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fa fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>

    <div class="social-link"><a href="https://github.com/Five-great/Five-great.github.io" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
    <i class="fa fa-github"></i>
</a>
<a href="mailto:https://985540932@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
    <i class="fa fa-envelope-open"></i>
</a>
<a href="#!" class="tooltipped" data-tooltip="QQ联系我: 985540932" data-position="top" data-delay="50">
    <i class="fa fa-qq"></i>
</a>

<a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
    <i class="fa fa-rss"></i>
</a>
</div>
</div>

            </div>
        </div>

        
        <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>
</header>

<!doctype html>

<head>
    <meta charset="utf-8" />
    <style>
    *{
        margin: 0;
        padding: 0;
    }
    #canvas{
		 position: fixed;
         background: #ccc;
		 overflow: auto;
		 z-index: -1;
    }
    </style> 

	<canvas id="canvas"></canvas>
	
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>
<body>
    
   
</body>
<script>
    window.requestAnimationFrame = (function(){
        return window.requestAnimationFrame ||
               window.webkitRequestAnimationFrame ||
               window.mozRequestAnimationFrame ||
               function( callback ){
                    window.setTimeout( callback, 1000/2 );
               };
    })();
    var myCanvas = document.getElementById("canvas");
    var ctx = myCanvas.getContext("2d");//getContext 设置画笔
    var num;
    var w,h;
    var duixiang = [];
    var move = {};
    function widthheight(){
        w = myCanvas.width = window.innerWidth;
        h = myCanvas.height = window.innerHeight;
		num= Math.floor(w*h*0.0001);
        for(var i = 0;i < num;i++){
            duixiang[i] = {
                x:Math.random()*w,
                y:Math.random()*h,
                cX:Math.random()*0.6-0.3,
                cY:Math.random()*0.6-0.3,
				R:Math.floor(Math.random()*5)+2,
				//CC:Math.floor(Math.random()*3)+2,
			    r: Math.floor(Math.random() * 254),   
                g: Math.floor(Math.random() * 254),  
                b:Math.floor(Math.random() * 254)   
            } 
           // console.log(duixiang[i])
            Cricle(duixiang[i].x,duixiang[i].y,duixiang[i].R,duixiang[i].r,duixiang[i].g,duixiang[i].b);
			 //Cricle(duixiang[i].x,duixiang[i].y,duixiang[i].R,duixiang[i].CC);
        }
    };widthheight();//获取浏览器的等宽度等高

    function Cricle(x,y,R,r,g,b){
        ctx.save();//保存路径
       if(Math.random()>0.991) {ctx.globalAlpha= 0.9;}//ctx.fillStyle = "#CCC";}//填充的背景颜色
	    else { ctx.globalAlpha=0.47;}
		 
		ctx.fillStyle = "rgb("+ r +","+ g +","+ b +")";
        ctx.beginPath();//开始绘画
		ctx.arc(x,y,R,Math.PI*2,0);//绘画圆 x y 半径（大小） 角度  一个PI 是180 * 2 = 360    真假 0/1 true/false
        ctx.closePath();//结束绘画
        ctx.fill();//填充背景颜色
        ctx.restore();//回复路径
    };Cricle();


    !function draw(){
        ctx.clearRect(0,0,w,h)//先清除画布上的点
        for(var i = 0;i < num;i++){
            duixiang[i].x += duixiang[i].cX;
            duixiang[i].y += duixiang[i].cY;
            if(duixiang[i].x>w || duixiang[i].x<0){
                duixiang[i].cX = -duixiang[i].cX;
            }
            if(duixiang[i].y>h || duixiang[i].y<0){
                duixiang[i].cY = -duixiang[i].cY;
            }
            Cricle(duixiang[i].x,duixiang[i].y,duixiang[i].R,duixiang[i].r,duixiang[i].g,duixiang[i].b);
            //勾股定理判断两点是否连线
            for(var j = i + 1;j < num;j++){
                if( (duixiang[i].x-duixiang[j].x)*(duixiang[i].x-duixiang[j].x)+(duixiang[i].y-duixiang[j].y)*(duixiang[i].y-duixiang[j].y) <= 55*55 ){
                    line(duixiang[i].x,duixiang[i].y,duixiang[j].x,duixiang[j].y,0,i,j)
                }
                if(move.x){
                    if( (duixiang[i].x-move.x)*(duixiang[i].x-move.x)+(duixiang[i].y-move.y)*(duixiang[i].y-move.y) <= 100*100 ){
                        line(duixiang[i].x,duixiang[i].y,move.x,move.y,1,i,1)
                    }
                }
            }
        }
        window.requestAnimationFrame(draw)
    }();

    //绘制线条
    function line(x1,y1,x2,y2,flag,i,j){
        
		if (flag){var color = ctx.createLinearGradient(x1,y1,x2,y2);
					ctx.globalAlpha=0.5;
					color.addColorStop(0,"rgb("+ duixiang[i].r +","+ duixiang[i].g +","+ duixiang[i].b +")");
					color.addColorStop(0.8,"#019ee5");
		        }
				else
				{
				
				var color = ctx.createLinearGradient(x1,y1,x2,y2);
					ctx.globalAlpha=0.9;
					color.addColorStop(0,"rgb("+ duixiang[i].r +","+ duixiang[i].g +","+ duixiang[i].b +")");
					color.addColorStop(1,"rgb("+ duixiang[j].r +","+ duixiang[j].g +","+ duixiang[j].b +")");
				}
        ctx.save();
        ctx.strokeStyle = color;
		ctx.lineWidth = 0.5;
        ctx.beginPath();
        ctx.moveTo(x1,y1);
        ctx.lineTo(x2,y2);
        ctx.stroke();
        //ctx.restore();
    }


    //document.onmousemove = function(e){
     //   move.x = e.clientX;
      //  move.y = e.clientY;
    //}
    //console.log(move)

    window.onresize = function(){
        location.reload();
    }
</script>















<div class="bg-cover post-cover" style="background-image: url('/medias/featureimages/15.jpg')">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        friend-斐波那契
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<main class="container content">

       
          <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            
            <div class="article-tag">
                
                <a href="/tags/ACM/" target="_blank">
                    <span class="chip bg-color">ACM</span>
                </a>
                
                <a href="/tags/水题/" target="_blank">
                    <span class="chip bg-color">水题</span>
                </a>
                
                <a href="/tags/快速幂/" target="_blank">
                    <span class="chip bg-color">快速幂</span>
                </a>
                
            </div>
            
			
            <div class="post-info">
                
                <span class="post-cate">
                    <i class="fa fa-bookmark fa-fw icon-category"></i>
                    
                    <a href="/categories/程序设计/" class="post-category" target="_blank">
                        程序设计
                    </a>
                    
                </span>
                

                <span class="post-date">
                    <i class="fa fa-clock-o fa-fw"></i>2018-10-04
                </span>
				<span id="busuanzi_container_page_pv" class="author-info" >
                  &nbsp;&nbsp;&nbsp;&nbsp;<span id="busuanzi_value_page_pv" class="icon fa fa-eye" >&nbsp;</span>次 
                   </span>
            </div>
        </div>
        <hr>
        <div class="card-content article-card-content">
            <div id="articleContent">
                <html><br><head><br><meta charset="UTF-8"><meta name="viewport" content="width=device-width initial-scale=1"><br><title>friend-斐波那契</title><style type="text/css">html {overflow-x: initial !important;}:root { –bg-color:#ffffff; –text-color:#333333; –select-text-bg-color:#B5D6FC; –select-text-font-color:auto; –monospace:”Lucida Console”,Consolas,”Courier”,monospace; }<br>html { font-size: 14px; background-color: var(–bg-color); color: var(–text-color); font-family: “Helvetica Neue”, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }<br>body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-size: 1rem; line-height: 1.42857; overflow-x: hidden; background: inherit; }<br>iframe { margin: auto; }<br>a.url { word-break: break-all; }<br>a:active, a:hover { outline: 0px; }<br>.in-text-selection, ::selection { text-shadow: none; background: var(–select-text-bg-color); color: var(–select-text-font-color); }<br>#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; word-wrap: break-word; position: relative; white-space: normal; padding-bottom: 70px; overflow-x: visible; }<br>.first-line-indent #write div, .first-line-indent #write li, .first-line-indent #write p { text-indent: 2em; }<br>.first-line-indent #write div :not(p):not(div), .first-line-indent #write div.md-htmlblock-container, .first-line-indent #write p <em>, .first-line-indent pre { text-indent: 0px; }<br>.for-image #write { padding-left: 8px; padding-right: 8px; }<br>body.typora-export { padding-left: 30px; padding-right: 30px; }<br>@media screen and (max-width: 500px) {<br>  body.typora-export { padding-left: 0px; padding-right: 0px; }<br>  .CodeMirror-sizer { margin-left: 0px !important; }<br>  .CodeMirror-gutters { display: none !important; }<br>}<br>#write &gt; blockquote:first-child, #write &gt; div:first-child, #write &gt; figure:first-child, #write &gt; ol:first-child, #write &gt; p:first-child, #write &gt; pre:first-child, #write &gt; ul:first-child { margin-top: 30px; }<br>#write li &gt; figure:first-child { margin-top: -20px; }<br>#write ol, #write ul { position: relative; }<br>img { max-width: 100%; vertical-align: middle; }<br>button, input, select, textarea { color: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; }<br>input[type=”checkbox”], input[type=”radio”] { line-height: normal; padding: 0px; }
</em>, ::after, ::before { box-sizing: border-box; }<br>#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p, #write pre { width: inherit; }<br>#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p { position: relative; }<br>h1, h2, h3, h4, h5, h6 { break-after: avoid-page; break-inside: avoid; orphans: 2; }<br>p { orphans: 4; }<br>h1 { font-size: 2rem; }<br>h2 { font-size: 1.8rem; }<br>h3 { font-size: 1.6rem; }<br>h4 { font-size: 1.4rem; }<br>h5 { font-size: 1.2rem; }<br>h6 { font-size: 1rem; }<br>.md-math-block, .md-rawblock, h1, h2, h3, h4, h5, h6, p { margin-top: 1rem; margin-bottom: 1rem; }<br>.hidden { display: none; }<br>.md-blockmeta { color: rgb(204, 204, 204); font-weight: 700; font-style: italic; }<br>a { cursor: pointer; }<br>sup.md-footnote { padding: 2px 4px; background-color: rgba(238, 238, 238, 0.7); color: rgb(85, 85, 85); border-radius: 4px; cursor: pointer; }<br>sup.md-footnote a, sup.md-footnote a:hover { color: inherit; text-transform: inherit; text-decoration: inherit; }<br>#write input[type=”checkbox”] { cursor: pointer; width: inherit; height: inherit; }<br>figure { overflow-x: auto; margin: 1.2em 0px; max-width: calc(100% + 16px); padding: 0px; }<br>figure &gt; table { margin: 0px !important; }<br>tr { break-inside: avoid; break-after: auto; }<br>thead { display: table-header-group; }<br>table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; break-inside: auto; text-align: left; }<br>table.md-table td { min-width: 80px; }<br>.CodeMirror-gutters { border-right: 0px; background-color: inherit; }<br>.CodeMirror { text-align: left; }<br>.CodeMirror-placeholder { opacity: 0.3; }<br>.CodeMirror pre { padding: 0px 4px; }<br>.CodeMirror-lines { padding: 0px; }<br>div.hr:focus { cursor: none; }<br>#write pre { white-space: pre-wrap; }<br>#write.fences-no-line-wrapping pre { white-space: pre; }<br>#write pre.ty-contain-cm { white-space: normal; }<br>.CodeMirror-gutters { margin-right: 4px; }<br>.md-fences { font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background: inherit; position: relative !important; }<br>.md-diagram-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }<br>#write .md-fences.mock-cm { white-space: pre-wrap; }<br>.md-fences.md-fences-with-lineno { padding-left: 0px; }<br>#write.fences-no-line-wrapping .md-fences.mock-cm { white-space: pre; overflow-x: auto; }<br>.md-fences.mock-cm.md-fences-with-lineno { padding-left: 8px; }<br>.CodeMirror-line, twitterwidget { break-inside: avoid; }<br>.footnotes { opacity: 0.8; font-size: 0.9rem; margin-top: 1em; margin-bottom: 1em; }<br>.footnotes + .footnotes { margin-top: 0px; }<br>.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background: 0px 0px; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; -webkit-tap-highlight-color: transparent; line-height: normal; font-weight: 400; text-align: left; box-sizing: content-box; direction: ltr; }<br>li div { padding-top: 0px; }<br>blockquote { margin: 1rem 0px; }<br>li .mathjax-block, li p { margin: 0.5rem 0px; }<br>li { margin: 0px; position: relative; }<br>blockquote &gt; :last-child { margin-bottom: 0px; }<br>blockquote &gt; :first-child, li &gt; :first-child { margin-top: 0px; }<br>.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; white-space: normal; }<br>#write .footnote-line { white-space: pre-wrap; }<br>@media print {<br>  body, html { border: 1px solid transparent; height: 99%; break-after: avoid; break-before: avoid; }<br>  #write { margin-top: 0px; border-color: transparent !important; }<br>  .typora-export <em> { -webkit-print-color-adjust: exact; }<br>  html.blink-to-pdf { font-size: 13px; }<br>  .typora-export #write { padding-left: 1cm; padding-right: 1cm; padding-bottom: 0px; break-after: avoid; }<br>  .typora-export #write::after { height: 0px; }<br>  @page { margin: 20mm 0px; }<br>}<br>.footnote-line { margin-top: 0.714em; font-size: 0.7em; }<br>a img, img a { cursor: pointer; }<br>pre.md-meta-block { font-size: 0.8rem; min-height: 0.8rem; white-space: pre-wrap; background: rgb(204, 204, 204); display: block; overflow-x: hidden; }<br>p &gt; img:only-child { display: block; margin: auto; }<br>p &gt; .md-image:only-child { display: inline-block; width: 100%; text-align: center; }<br>#write .MathJax_Display { margin: 0.8em 0px 0px; }<br>.md-math-block { width: 100%; }<br>.md-math-block:not(:empty)::after { display: none; }<br>[contenteditable=”true”]:active, [contenteditable=”true”]:focus { outline: 0px; box-shadow: none; }<br>.md-task-list-item { position: relative; list-style-type: none; }<br>.task-list-item.md-task-list-item { padding-left: 0px; }<br>.md-task-list-item &gt; input { position: absolute; top: 0px; left: 0px; margin-left: -1.2em; margin-top: calc(1em - 10px); }<br>.math { font-size: 1rem; }<br>.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-radius: 10px; }<br>.md-toc-content { position: relative; margin-left: 0px; }<br>.md-toc-content::after, .md-toc::after { display: none; }<br>.md-toc-item { display: block; color: rgb(65, 131, 196); }<br>.md-toc-item a { text-decoration: none; }<br>.md-toc-inner:hover { }<br>.md-toc-inner { display: inline-block; cursor: pointer; }<br>.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: 700; }<br>.md-toc-h2 .md-toc-inner { margin-left: 2em; }<br>.md-toc-h3 .md-toc-inner { margin-left: 4em; }<br>.md-toc-h4 .md-toc-inner { margin-left: 6em; }<br>.md-toc-h5 .md-toc-inner { margin-left: 8em; }<br>.md-toc-h6 .md-toc-inner { margin-left: 10em; }<br>@media screen and (max-width: 48em) {<br>  .md-toc-h3 .md-toc-inner { margin-left: 3.5em; }<br>  .md-toc-h4 .md-toc-inner { margin-left: 5em; }<br>  .md-toc-h5 .md-toc-inner { margin-left: 6.5em; }<br>  .md-toc-h6 .md-toc-inner { margin-left: 8em; }<br>}<br>a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }<br>.footnote-line a:not(.reversefootnote) { color: inherit; }<br>.md-attr { display: none; }<br>.md-fn-count::after { content: “.”; }<br>code, pre, samp, tt { font-family: var(–monospace); }<br>kbd { margin: 0px 0.1em; padding: 0.1em 0.6em; font-size: 0.8em; color: rgb(36, 39, 41); background: rgb(255, 255, 255); border: 1px solid rgb(173, 179, 185); border-radius: 3px; box-shadow: rgba(12, 13, 14, 0.2) 0px 1px 0px, rgb(255, 255, 255) 0px 0px 0px 2px inset; white-space: nowrap; vertical-align: middle; }<br>.md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: var(–monospace); }<br>code { text-align: left; vertical-align: initial; }<br>a.md-print-anchor { white-space: pre !important; border-width: initial !important; border-style: none !important; border-color: initial !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: 0px !important; background: 0px 0px !important; text-decoration: initial !important; text-shadow: initial !important; }<br>.md-inline-math .MathJax_SVG .noError { display: none !important; }<br>.md-math-block .MathJax_SVG_Display { text-align: center; margin: 0px; position: relative; text-indent: 0px; max-width: none; max-height: none; min-height: 0px; min-width: 100%; width: auto; overflow-y: hidden; display: block !important; }<br>.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }<br>.MathJax_SVG .MJX-monospace { font-family: var(–monospace); }<br>.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }<br>.MathJax_SVG { display: inline; font-style: normal; font-weight: 400; line-height: normal; zoom: 90%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; }<br>.MathJax_SVG </em> { transition: none; }<br>.MathJax_SVG_Display svg { vertical-align: middle !important; margin-bottom: 0px !important; }<br>.os-windows.monocolor-emoji .md-emoji { font-family: “Segoe UI Symbol”, sans-serif; }<br>.md-diagram-panel &gt; svg { max-width: 100%; }<br>[lang=”mermaid”] svg, [lang=”flow”] svg { max-width: 100%; }<br>[lang=”mermaid”] .node text { font-size: 1rem; }<br>table tr th { border-bottom: 0px; }<br>video { max-width: 100%; display: block; margin: 0px auto; }<br>iframe { max-width: 100%; width: 100%; border: none; }<br>.highlight td, .highlight tr { border: 0px; }<br><br><br>.CodeMirror { height: auto; }<br>.CodeMirror.cm-s-inner { background: inherit; }<br>.CodeMirror-scroll { overflow-y: hidden; overflow-x: auto; z-index: 3; }<br>.CodeMirror-gutter-filler, .CodeMirror-scrollbar-filler { background-color: rgb(255, 255, 255); }<br>.CodeMirror-gutters { border-right: 1px solid rgb(221, 221, 221); background: inherit; white-space: nowrap; }<br>.CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); }<br>.cm-s-inner .cm-keyword { color: rgb(119, 0, 136); }<br>.cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); }<br>.cm-s-inner .cm-number { color: rgb(17, 102, 68); }<br>.cm-s-inner .cm-def { color: rgb(0, 0, 255); }<br>.cm-s-inner .cm-variable { color: rgb(0, 0, 0); }<br>.cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); }<br>.cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); }<br>.cm-s-inner .cm-string { color: rgb(170, 17, 17); }<br>.cm-s-inner .cm-property { color: rgb(0, 0, 0); }<br>.cm-s-inner .cm-operator { color: rgb(152, 26, 26); }<br>.cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); }<br>.cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); }<br>.cm-s-inner .cm-meta { color: rgb(85, 85, 85); }<br>.cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); }<br>.cm-s-inner .cm-builtin { color: rgb(51, 0, 170); }<br>.cm-s-inner .cm-bracket { color: rgb(153, 153, 119); }<br>.cm-s-inner .cm-tag { color: rgb(17, 119, 0); }<br>.cm-s-inner .cm-attribute { color: rgb(0, 0, 204); }<br>.cm-s-inner .cm-header, .cm-s-inner.cm-header { color: rgb(0, 0, 255); }<br>.cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); }<br>.cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); }<br>.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); }<br>.cm-negative { color: rgb(221, 68, 68); }<br>.cm-positive { color: rgb(34, 153, 34); }<br>.cm-header, .cm-strong { font-weight: 700; }<br>.cm-del { text-decoration: line-through; }<br>.cm-em { font-style: italic; }<br>.cm-link { text-decoration: underline; }<br>.cm-error { color: red; }<br>.cm-invalidchar { color: red; }<br>.cm-constant { color: rgb(38, 139, 210); }<br>.cm-defined { color: rgb(181, 137, 0); }<br>div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }<br>div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }<br>.cm-s-inner .CodeMirror-activeline-background { background: inherit; }<br>.CodeMirror { position: relative; overflow: hidden; }<br>.CodeMirror-scroll { height: 100%; outline: 0px; position: relative; box-sizing: content-box; background: inherit; }<br>.CodeMirror-sizer { position: relative; }<br>.CodeMirror-gutter-filler, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-vscrollbar { position: absolute; z-index: 6; display: none; }<br>.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow: hidden; }<br>.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow: hidden; }<br>.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }<br>.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }<br>.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 30px; z-index: 3; }<br>.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }<br>.CodeMirror-gutter-wrapper { position: absolute; z-index: 4; background: 0px 0px !important; border: none !important; }<br>.CodeMirror-gutter-background { position: absolute; top: 0px; bottom: 0px; z-index: 4; }<br>.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }<br>.CodeMirror-lines { cursor: text; }<br>.CodeMirror pre { border-radius: 0px; border-width: 0px; background: 0px 0px; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; word-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; }<br>.CodeMirror-wrap pre { word-wrap: break-word; white-space: pre-wrap; word-break: normal; }<br>.CodeMirror-code pre { border-right: 30px solid transparent; width: fit-content; }<br>.CodeMirror-wrap .CodeMirror-code pre { border-right: none; width: auto; }<br>.CodeMirror-linebackground { position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 0; }<br>.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }<br>.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }<br>.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }<br>.CodeMirror-measure pre { position: static; }<br>.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right: none; width: 0px; }<br>.CodeMirror div.CodeMirror-cursor { visibility: hidden; }<br>.CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; }<br>.cm-searching { background: rgba(255, 255, 0, 0.4); }<br>@media print {<br>  .CodeMirror div.CodeMirror-cursor { visibility: hidden; }<br>}<br><br><br>:root { –side-bar-bg-color: #fff; –control-text-color: #777; }<br>@font-face { font-family: “Roboto Mono”; font-style: normal; font-weight: 400; src: local(“Roboto Mono”), local(“RobotoMono-Regular”), url(“vue/L0x5DF4xlVMF-BfR8bXMIjhGq3-cXbKDO1w.woff2”) format(“woff2”); unicode-range: U+460-52F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }<br>@font-face { font-family: “Roboto Mono”; font-style: normal; font-weight: 400; src: local(“Roboto Mono”), local(“RobotoMono-Regular”), url(“vue/L0x5DF4xlVMF-BfR8bXMIjhPq3-cXbKDO1w.woff2”) format(“woff2”); unicode-range: U+400-45F, U+490-491, U+4B0-4B1, U+2116; }<br>@font-face { font-family: “Roboto Mono”; font-style: normal; font-weight: 400; src: local(“Roboto Mono”), local(“RobotoMono-Regular”), url(“vue/L0x5DF4xlVMF-BfR8bXMIjhHq3-cXbKDO1w.woff2”) format(“woff2”); unicode-range: U+1F00-1FFF; }<br>@font-face { font-family: “Roboto Mono”; font-style: normal; font-weight: 400; src: local(“Roboto Mono”), local(“RobotoMono-Regular”), url(“vue/L0x5DF4xlVMF-BfR8bXMIjhIq3-cXbKDO1w.woff2”) format(“woff2”); unicode-range: U+370-3FF; }<br>@font-face { font-family: “Roboto Mono”; font-style: normal; font-weight: 400; src: local(“Roboto Mono”), local(“RobotoMono-Regular”), url(“vue/L0x5DF4xlVMF-BfR8bXMIjhEq3-cXbKDO1w.woff2”) format(“woff2”); unicode-range: U+102-103, U+110-111, U+1EA0-1EF9, U+20AB; }<br>@font-face { font-family: “Roboto Mono”; font-style: normal; font-weight: 400; src: local(“Roboto Mono”), local(“RobotoMono-Regular”), url(“vue/L0x5DF4xlVMF-BfR8bXMIjhFq3-cXbKDO1w.woff2”) format(“woff2”); unicode-range: U+100-24F, U+259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }<br>@font-face { font-family: “Roboto Mono”; font-style: normal; font-weight: 400; src: local(“Roboto Mono”), local(“RobotoMono-Regular”), url(“vue/L0x5DF4xlVMF-BfR8bXMIjhLq3-cXbKD.woff2”) format(“woff2”); unicode-range: U+0-FF, U+131, U+152-153, U+2BB-2BC, U+2C6, U+2DA, U+2DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 300; src: local(“Source Sans Pro Light”), local(“SourceSansPro-Light”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3ik4zwmhduz8A.woff2”) format(“woff2”); unicode-range: U+460-52F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 300; src: local(“Source Sans Pro Light”), local(“SourceSansPro-Light”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3ik4zwkxduz8A.woff2”) format(“woff2”); unicode-range: U+400-45F, U+490-491, U+4B0-4B1, U+2116; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 300; src: local(“Source Sans Pro Light”), local(“SourceSansPro-Light”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3ik4zwmxduz8A.woff2”) format(“woff2”); unicode-range: U+1F00-1FFF; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 300; src: local(“Source Sans Pro Light”), local(“SourceSansPro-Light”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3ik4zwlBduz8A.woff2”) format(“woff2”); unicode-range: U+370-3FF; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 300; src: local(“Source Sans Pro Light”), local(“SourceSansPro-Light”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3ik4zwmBduz8A.woff2”) format(“woff2”); unicode-range: U+102-103, U+110-111, U+1EA0-1EF9, U+20AB; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 300; src: local(“Source Sans Pro Light”), local(“SourceSansPro-Light”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3ik4zwmRduz8A.woff2”) format(“woff2”); unicode-range: U+100-24F, U+259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 300; src: local(“Source Sans Pro Light”), local(“SourceSansPro-Light”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3ik4zwlxdu.woff2”) format(“woff2”); unicode-range: U+0-FF, U+131, U+152-153, U+2BB-2BC, U+2C6, U+2DA, U+2DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 400; src: local(“Source Sans Pro Regular”), local(“SourceSansPro-Regular”), url(“vue/6xK3dSBYKcSV-LCoeQqfX1RYOo3qNa7lqDY.woff2”) format(“woff2”); unicode-range: U+460-52F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 400; src: local(“Source Sans Pro Regular”), local(“SourceSansPro-Regular”), url(“vue/6xK3dSBYKcSV-LCoeQqfX1RYOo3qPK7lqDY.woff2”) format(“woff2”); unicode-range: U+400-45F, U+490-491, U+4B0-4B1, U+2116; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 400; src: local(“Source Sans Pro Regular”), local(“SourceSansPro-Regular”), url(“vue/6xK3dSBYKcSV-LCoeQqfX1RYOo3qNK7lqDY.woff2”) format(“woff2”); unicode-range: U+1F00-1FFF; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 400; src: local(“Source Sans Pro Regular”), local(“SourceSansPro-Regular”), url(“vue/6xK3dSBYKcSV-LCoeQqfX1RYOo3qO67lqDY.woff2”) format(“woff2”); unicode-range: U+370-3FF; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 400; src: local(“Source Sans Pro Regular”), local(“SourceSansPro-Regular”), url(“vue/6xK3dSBYKcSV-LCoeQqfX1RYOo3qN67lqDY.woff2”) format(“woff2”); unicode-range: U+102-103, U+110-111, U+1EA0-1EF9, U+20AB; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 400; src: local(“Source Sans Pro Regular”), local(“SourceSansPro-Regular”), url(“vue/6xK3dSBYKcSV-LCoeQqfX1RYOo3qNq7lqDY.woff2”) format(“woff2”); unicode-range: U+100-24F, U+259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 400; src: local(“Source Sans Pro Regular”), local(“SourceSansPro-Regular”), url(“vue/6xK3dSBYKcSV-LCoeQqfX1RYOo3qOK7l.woff2”) format(“woff2”); unicode-range: U+0-FF, U+131, U+152-153, U+2BB-2BC, U+2C6, U+2DA, U+2DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 600; src: local(“Source Sans Pro SemiBold”), local(“SourceSansPro-SemiBold”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3i54rwmhduz8A.woff2”) format(“woff2”); unicode-range: U+460-52F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 600; src: local(“Source Sans Pro SemiBold”), local(“SourceSansPro-SemiBold”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3i54rwkxduz8A.woff2”) format(“woff2”); unicode-range: U+400-45F, U+490-491, U+4B0-4B1, U+2116; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 600; src: local(“Source Sans Pro SemiBold”), local(“SourceSansPro-SemiBold”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3i54rwmxduz8A.woff2”) format(“woff2”); unicode-range: U+1F00-1FFF; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 600; src: local(“Source Sans Pro SemiBold”), local(“SourceSansPro-SemiBold”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3i54rwlBduz8A.woff2”) format(“woff2”); unicode-range: U+370-3FF; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 600; src: local(“Source Sans Pro SemiBold”), local(“SourceSansPro-SemiBold”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3i54rwmBduz8A.woff2”) format(“woff2”); unicode-range: U+102-103, U+110-111, U+1EA0-1EF9, U+20AB; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 600; src: local(“Source Sans Pro SemiBold”), local(“SourceSansPro-SemiBold”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3i54rwmRduz8A.woff2”) format(“woff2”); unicode-range: U+100-24F, U+259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }<br>@font-face { font-family: “Source Sans Pro”; font-style: normal; font-weight: 600; src: local(“Source Sans Pro SemiBold”), local(“SourceSansPro-SemiBold”), url(“vue/6xKydSBYKcSV-LCoeQqfX1RYOo3i54rwlxdu.woff2”) format(“woff2”); unicode-range: U+0-FF, U+131, U+152-153, U+2BB-2BC, U+2C6, U+2DA, U+2DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }<br>html { font-size: 16px; }<br>body { color: rgb(52, 73, 94); -webkit-font-smoothing: antialiased; line-height: 1.6rem; letter-spacing: 0px; margin: 0px; overflow-x: hidden; font-family: “Source Sans Pro”, “Helvetica Neue”, Arial, sans-serif !important; }<br>#write { max-width: 860px; margin: 0px auto; padding: 20px 30px 100px; }<br>#write p { line-height: 1.6rem; word-spacing: 0.05rem; }<br>#write ol li { padding-left: 0.5rem; }<br>#write &gt; ul:first-child, #write &gt; ol:first-child { margin-top: 30px; }<br>body &gt; :first-child { margin-top: 0px !important; }<br>body &gt; :last-child { margin-bottom: 0px !important; }<br>a { color: rgb(66, 185, 131); font-weight: 600; padding: 0px 2px; text-decoration: none; }<br>h1, h2, h3, h4, h5, h6 { position: relative; margin-top: 1rem; margin-bottom: 1rem; font-weight: bold; line-height: 1.4; cursor: text; }<br>h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor { text-decoration: none; }<br>h1 tt, h1 code { font-size: inherit; }<br>h2 tt, h2 code { font-size: inherit; }<br>h3 tt, h3 code { font-size: inherit; }<br>h4 tt, h4 code { font-size: inherit; }<br>h5 tt, h5 code { font-size: inherit; }<br>h6 tt, h6 code { font-size: inherit; }<br>h2 a, h3 a { color: rgb(52, 73, 94); }<br>h3 a::before { content: “#”; color: rgb(66, 185, 131); position: absolute; left: -0.7em; margin-top: -0.05em; padding-right: 0.5em; font-size: 1.2em; line-height: 1; font-weight: bold; }<br>h1 { padding-bottom: 0.4rem; font-size: 2.2rem; line-height: 1.3; }<br>h2 { font-size: 1.75rem; line-height: 1.225; margin: 35px 0px 15px; padding-bottom: 0.5em; border-bottom: 1px solid rgb(221, 221, 221); }<br>h3 { font-size: 1.4rem; line-height: 1.43; margin: 20px 0px 7px; }<br>h4 { font-size: 1.2rem; }<br>h5 { font-size: 1rem; }<br>h6 { font-size: 1rem; color: rgb(119, 119, 119); }<br>p, blockquote, ul, ol, dl, table { margin: 0.8em 0px; }<br>li &gt; ol, li &gt; ul { margin: 0px; }<br>hr { height: 2px; padding: 0px; margin: 16px 0px; background-color: rgb(231, 231, 231); border: 0px none; overflow: hidden; box-sizing: content-box; }<br>body &gt; h2:first-child { margin-top: 0px; padding-top: 0px; }<br>body &gt; h1:first-child { margin-top: 0px; padding-top: 0px; }<br>body &gt; h1:first-child + h2 { margin-top: 0px; padding-top: 0px; }<br>body &gt; h3:first-child, body &gt; h4:first-child, body &gt; h5:first-child, body &gt; h6:first-child { margin-top: 0px; padding-top: 0px; }<br>a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 { margin-top: 0px; padding-top: 0px; }<br>h1 p, h2 p, h3 p, h4 p, h5 p, h6 p { margin-top: 0px; }<br>li p.first { display: inline-block; }<br>ul, ol { padding-left: 30px; }<br>ul:first-child, ol:first-child { margin-top: 0px; }<br>ul:last-child, ol:last-child { margin-bottom: 0px; }<br>blockquote { border-left: 4px solid rgb(66, 185, 131); padding: 10px 0px 10px 15px; color: rgb(119, 119, 119); background-color: rgba(66, 185, 131, 0.1); }<br>table { padding: 0px; word-break: initial; }<br>table tr { border-top: 1px solid rgb(223, 226, 229); margin: 0px; padding: 0px; }<br>table tr:nth-child(2n), thead { background-color: rgb(250, 250, 250); }<br>table tr th { font-weight: bold; border-width: 1px 1px 0px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-top-color: rgb(223, 226, 229); border-right-color: rgb(223, 226, 229); border-left-color: rgb(223, 226, 229); border-image: initial; border-bottom-style: initial; border-bottom-color: initial; text-align: left; margin: 0px; padding: 6px 13px; }<br>table tr td { border: 1px solid rgb(223, 226, 229); text-align: left; margin: 0px; padding: 6px 13px; }<br>table tr th:first-child, table tr td:first-child { margin-top: 0px; }<br>table tr th:last-child, table tr td:last-child { margin-bottom: 0px; }<br>#write strong { padding: 0px 1px; }<br>#write em { padding: 0px 5px 0px 2px; }<br>#write table thead th { background-color: rgb(242, 242, 242); }<br>#write .CodeMirror-gutters { border-right: none; }<br>#write .md-fences { border: 1px solid rgb(244, 244, 244); -webkit-font-smoothing: initial; line-height: 1.43rem; border-radius: 2px; font-size: 0.85rem; word-wrap: normal; margin: 0.8rem 0px !important; padding: 0.3rem 0rem !important; background-color: rgb(248, 248, 248) !important; font-family: “Roboto Mono”, “Source Sans Pro”, Monaco, courier, monospace !important; }<br>#write .CodeMirror-wrap .CodeMirror-code pre { padding-left: 12px; }<br>#write code, tt { margin: 0px 2px; padding: 2px 4px; border-radius: 2px; font-size: 0.92rem; color: rgb(233, 105, 0); background-color: rgb(248, 248, 248); font-family: “Source Sans Pro”, “Roboto Mono”, Monaco, courier, monospace !important; }<br>#write .md-footnote { background-color: rgb(248, 248, 248); color: rgb(233, 105, 0); }<br>#write mark { background-color: rgb(235, 255, 235); border-radius: 2px; padding: 2px 4px; margin: 0px 2px; color: rgb(34, 34, 34); font-weight: 500; }<br>#write del { padding: 1px 2px; }<br>.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(34, 162, 201); }<br>.cm-s-inner .cm-string { color: rgb(34, 162, 201); }<br>.md-task-list-item &gt; input { margin-left: -1.3em; }<br>@media screen and (min-width: 914px) {<br>}<br>@media print {<br>  html { font-size: 13px; }<br>  table, pre { break-inside: avoid; }<br>  pre { word-wrap: break-word; }<br>}<br>.md-fences { background-color: rgb(248, 248, 248); }<br>#write pre.md-meta-block { padding: 1rem; font-size: 85%; line-height: 1.45; background-color: rgb(247, 247, 247); border: 0px; border-radius: 3px; color: rgb(119, 119, 119); margin-top: 0px !important; }<br>.mathjax-block &gt; .code-tooltip { bottom: 0.375rem; }<br>#write &gt; h3.md-focus::before { left: -1.5625rem; top: 0.375rem; }<br>#write &gt; h4.md-focus::before { left: -1.5625rem; top: 0.285714rem; }<br>#write &gt; h5.md-focus::before { left: -1.5625rem; top: 0.285714rem; }<br>#write &gt; h6.md-focus::before { left: -1.5625rem; top: 0.285714rem; }<br>.md-image &gt; .md-meta { border-radius: 3px; font-family: Consolas, “Liberation Mono”, Courier, monospace; padding: 2px 0px 0px 4px; font-size: 0.9em; color: inherit; }<br>.md-tag { color: inherit; }<br>.md-toc { margin-top: 20px; padding-bottom: 20px; }<br>.sidebar-tabs { border-bottom: none; }<br>#typora-quick-open { border: 1px solid rgb(221, 221, 221); background-color: rgb(248, 248, 248); }<br>#typora-quick-open-item { background-color: rgb(250, 250, 250); border-color: rgb(254, 254, 254) rgb(229, 229, 229) rgb(229, 229, 229) rgb(238, 238, 238); border-style: solid; border-width: 1px; }<br>#md-notification::before { top: 10px; }<br>.on-focus-mode blockquote { border-left-color: rgba(85, 85, 85, 0.12); }<br>header, .context-menu, .megamenu-content, footer { font-family: “Segoe UI”, Arial, sans-serif; }<br>.file-node-content:hover .file-node-icon, .file-node-content:hover .file-node-open-state { visibility: visible; }<br>.mac-seamless-mode #typora-sidebar { background-color: var(–side-bar-bg-color); }<br>.md-lang { color: rgb(180, 101, 77); }<br>.html-for-mac .context-menu { –item-hover-bg-color: #E6F0FE; }<br><br><br><br><br><br> .typora-export p, .typora-export .footnote-line {white-space: normal;}<br></style><br><link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head><br><body class="typora-export os-windows"><br><div id="write" class="is-node"><h1><a name="header-n2" class="md-header-anchor "></a>6264. friend-斐波那契</h1><p> </p><hr><p>Description</p><p>求f12+f22+f32+….+fn2， 其中 fi 代表斐波那契数列的第 i 项。 (f0=0,f1=1)当然结果会很大，请将它对 109+7取模。</p><p>输入格式</p><p>一行一个数 n.</p><p>输出格式</p><p>一行一个数，代表答案。</p><p>样例</p><p>样例输入</p><blockquote><p>6</p></blockquote><p>样例输出</p><blockquote><p>104</p></blockquote><p>数据范围与提示</p><p>对于30%的数据：n≤105。</p><p>对于另外20%的数据: 1000000∣n （即n是1000000的倍数），且n≤5∗109。</p><p>对于100%的数据：n≤1018。</p><p> </p><hr><p> </p><p>解体思路：首先需要搞清楚斐波那契数列求和蕴含的规律，先找到它的递归形式：</p><p><img src="file:///C:/Users/LHL/AppData/Local/Temp/msohtmlclip1/01/clip_image002.jpg" alt="img" referrerpolicy="no-referrer"></p><p>则其各项相加的平方和为：</p><p><img src="file:///C:/Users/LHL/AppData/Local/Temp/msohtmlclip1/01/clip_image004.jpg" alt="img" referrerpolicy="no-referrer"></p><p>以几何的手段证明：12+12+22+32+52+82=8×13</p><p><img src="file:///C:/Users/LHL/AppData/Local/Temp/msohtmlclip1/01/clip_image006.jpg" alt="img" referrerpolicy="no-referrer"></p><p>设斐波那契数列的各项为正方形边长，则所求平方和就是算正方形的面积，但是求幂运算需要循环逐个累乘，其复杂度为O(n)，这在很多时候是不够的，所以我们需要用快速幂——反复平方法来加速幂运算的过程，要想办法减少步骤，把其中的某一部分合成一步来进行。</p><p>比如，如果n能被2整除，那我们可以先计算一半，得到a^(n/2)的值，再把这个值平方得出结果。这样做虽然有优化，但优化的程度很小，仍是线性的复杂度。</p><p>再比如，如果我们能找到2k = n，那我们就能把原来的运算优化成((((a2) 2) 2)…)，只需要k次运算就可以完成，效率大大提升。可惜的是，这种条件显然太苛刻了，适用范围很小。不过这给了我们一种思路，虽然我们很难找到2k == n，但我们能够找到2k1 + 2k2 + 2k3 +……+ 2km =n。这样，我们可以通过层层递推，在很短的时间内求出各个项的值。可是又有新的问题出现了，我们并不清楚k1、k2…km具体的值是多少，对于不同的n，有不同分法，有没有一种规则能把这些分法统一起来。</p><p>我们都学习过进制与进制的转换，知道一个b进制数的值可以表示为各个数位的值与权值之积的总和。比如，2进制数1001，它的值可以表示为10进制的1<em>23 + 0</em>22 + 0<em>21 + 1</em>20，即9。这完美地符合了上面的要求。可以通过2进制来把n转化成2^km的序列之和，而2进制中第i位（从右边开始计数，值为1或是0）则标记了对应的2(i - 1)是否存在于序列之中。譬如，13为二进制的1101，他可以表示为23 + 22 + 20，其中由于第二位为0，21项被舍去。</p><p>如此一来，我们只需要计算a、a2、a4、a8……的值（这个序列中的项不一定都存在）并把它们乘起来即可完成整个幂运算。借助位运算的操作，可以很方便地实现这一算法，其复杂度为O(logn)。</p><p>套用以下模板：</p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="c++" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="c++"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 12px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><span><span>​</span>x</span></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">typedef</span> <span class="cm-variable-3">long</span> <span class="cm-variable-3">long</span> <span class="cm-variable">ll</span>;</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">ll</span> <span class="cm-def">quick_pow</span>(<span class="cm-variable">ll</span> <span class="cm-variable">a</span>, <span class="cm-variable">ll</span> <span class="cm-variable">n</span>)<span class="cm-comment">//a^n</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">{</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; <span class="cm-variable">ll</span> <span class="cm-variable">re</span> <span class="cm-operator">=</span> <span class="cm-number">1</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; <span class="cm-keyword">while</span>(<span class="cm-variable">n</span> <span class="cm-operator">!=</span> <span class="cm-number">0</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; {</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; <span class="cm-keyword">if</span>(<span class="cm-variable">n</span> <span class="cm-operator">&amp;</span> <span class="cm-number">1</span>)<span class="cm-comment">//判断n的最后一位是1还是0</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">re</span> <span class="cm-operator"><em>=</em></span> <span class="cm-variable">a</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; <span class="cm-variable">a</span> <span class="cm-operator">=</span> (<span class="cm-variable">a</span> <span class="cm-operator"></span> <span class="cm-variable">a</span>);<span class="cm-comment">//将a平方，即把a^(2^i)变为a^(2^(i + 1))</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">n</span> <span class="cm-operator">&gt;&gt;=</span> <span class="cm-number">1</span>;<span class="cm-comment">//n右移一位，舍去n的最后一位</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  }</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-keyword">return</span> <span class="cm-variable">re</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">}</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 476px;"></div><div class="CodeMirror-gutters" style="display: none; height: 476px;"></div></div></div></pre><p>本题需要取模，直接在每一步运算中对a和re取模即可。</p><p> AC代码：</p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="c" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="c"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 12px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include&lt;string.h&gt;</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include&lt;stdio.h&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#define ll long long</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#define MOD 1000000007</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">struct</span> <span class="cm-def">nobe</span>{ <span class="cm-variable">ll</span> <span class="cm-variable">a</span>[<span class="cm-number">2</span>][<span class="cm-number">2</span>];};</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">ll</span> <span class="cm-variable">n</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">ll</span> <span class="cm-variable">sum</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">nobe</span> <span class="cm-def">mut</span>(<span class="cm-variable">nobe</span> <span class="cm-variable">x</span>,<span class="cm-variable">nobe</span> <span class="cm-variable">y</span>){</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">nobe</span> <span class="cm-variable">res</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">memset</span>(<span class="cm-variable">res</span>.<span class="cm-variable">a</span>,<span class="cm-number">0</span>,<span class="cm-keyword">sizeof</span>(<span class="cm-variable">res</span>.<span class="cm-variable">a</span>));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">for</span>(<span class="cm-variable">ll</span> <span class="cm-variable">i</span><span class="cm-operator">=</span><span class="cm-number">0</span>;<span class="cm-variable">i</span><span class="cm-operator">&lt;</span><span class="cm-number">2</span>;<span class="cm-variable">i</span><span class="cm-operator">++</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-keyword">for</span>( <span class="cm-variable-3">int</span> <span class="cm-variable">j</span><span class="cm-operator">=</span><span class="cm-number">0</span>;<span class="cm-variable">j</span><span class="cm-operator">&lt;</span><span class="cm-number">2</span>;<span class="cm-variable">j</span><span class="cm-operator">++</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-keyword">for</span>( <span class="cm-variable-3">int</span> <span class="cm-variable">k</span><span class="cm-operator">=</span><span class="cm-number">0</span>;<span class="cm-variable">k</span><span class="cm-operator">&lt;</span><span class="cm-number">2</span>;<span class="cm-variable">k</span><span class="cm-operator">++</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-variable">res</span>.<span class="cm-variable">a</span>[<span class="cm-variable">i</span>][<span class="cm-variable">j</span>]<span class="cm-operator">=</span>(<span class="cm-variable">res</span>.<span class="cm-variable">a</span>[<span class="cm-variable">i</span>][<span class="cm-variable">j</span>]<span class="cm-operator">+</span><span class="cm-variable">x</span>.<span class="cm-variable">a</span>[<span class="cm-variable">i</span>][<span class="cm-variable">k</span>]<span class="cm-operator"><em></em></span><span class="cm-variable">y</span>.<span class="cm-variable">a</span>[<span class="cm-variable">k</span>][<span class="cm-variable">j</span>])<span class="cm-operator">%</span><span class="cm-variable">MOD</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">return</span> <span class="cm-variable">res</span>;}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable-3">void</span> <span class="cm-def">quick</span>(<span class="cm-variable">ll</span> <span class="cm-variable">n</span>){</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-variable">nobe</span> <span class="cm-variable">c</span>,<span class="cm-variable">res</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">c</span>.<span class="cm-variable">a</span>[<span class="cm-number">0</span>][<span class="cm-number">0</span>]<span class="cm-operator">=</span><span class="cm-number">1</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">c</span>.<span class="cm-variable">a</span>[<span class="cm-number">0</span>][<span class="cm-number">1</span>]<span class="cm-operator">=</span><span class="cm-number">1</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">c</span>.<span class="cm-variable">a</span>[<span class="cm-number">1</span>][<span class="cm-number">0</span>]<span class="cm-operator">=</span><span class="cm-number">1</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">c</span>.<span class="cm-variable">a</span>[<span class="cm-number">1</span>][<span class="cm-number">1</span>]<span class="cm-operator">=</span><span class="cm-number">0</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">memset</span>(<span class="cm-variable">res</span>.<span class="cm-variable">a</span>,<span class="cm-number">0</span>,<span class="cm-keyword">sizeof</span>(<span class="cm-variable">res</span>.<span class="cm-variable">a</span>));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-keyword">for</span>(<span class="cm-variable-3">int</span> <span class="cm-variable">i</span><span class="cm-operator">=</span><span class="cm-number">0</span>;<span class="cm-variable">i</span><span class="cm-operator">&lt;</span><span class="cm-number">2</span>;<span class="cm-variable">i</span><span class="cm-operator">++</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">res</span>.<span class="cm-variable">a</span>[<span class="cm-variable">i</span>][<span class="cm-variable">i</span>]<span class="cm-operator">=</span><span class="cm-number">1</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-keyword">while</span>(<span class="cm-variable">n</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;  { &nbsp;<span class="cm-variable">cont</span><span class="cm-operator">++</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-keyword">if</span>(<span class="cm-variable">n</span><span class="cm-operator">&amp;</span><span class="cm-number">1</span>)<span class="cm-variable">res</span><span class="cm-operator">=</span><span class="cm-variable">mut</span>(<span class="cm-variable">res</span>,<span class="cm-variable">c</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">c</span><span class="cm-operator">=</span><span class="cm-variable">mut</span>(<span class="cm-variable">c</span>,<span class="cm-variable">c</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-variable">n</span><span class="cm-operator">=</span><span class="cm-variable">n</span><span class="cm-operator">&gt;&gt;</span><span class="cm-number">1</span>; &nbsp;  }</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">printf</span>(<span class="cm-string">“%ld\n”</span>,((<span class="cm-variable">res</span>.<span class="cm-variable">a</span>[<span class="cm-number">0</span>][<span class="cm-number">1</span>]<span class="cm-operator">%</span><span class="cm-variable">MOD</span>)<span class="cm-operator"></span>(<span class="cm-variable">res</span>.<span class="cm-variable">a</span>[<span class="cm-number">0</span>][<span class="cm-number">1</span>]<span class="cm-operator">%</span><span class="cm-variable">MOD</span><span class="cm-operator">+</span><span class="cm-variable">res</span>.<span class="cm-variable">a</span>[<span class="cm-number">1</span>][<span class="cm-number">1</span>]<span class="cm-operator">%</span><span class="cm-variable">MOD</span>))<span class="cm-operator">%</span><span class="cm-variable">MOD</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable-3">int</span> <span class="cm-def">main</span>(){</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-keyword">while</span>(<span class="cm-variable">scanf</span>(<span class="cm-string">“%ld”</span>,<span class="cm-operator">&amp;</span><span class="cm-variable">n</span>)<span class="cm-operator">!=</span><span class="cm-variable">EOF</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  { &nbsp; &nbsp; <span class="cm-variable">quick</span>(<span class="cm-variable">n</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  }</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">return</span> <span class="cm-number">0</span>;}</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 839px;"></div><div class="CodeMirror-gutters" style="display: none; height: 839px;"></div></div></div></pre><p>&nbsp;</p></div><br></body><br></html>















<pre class=" language-c"><code class="language-c"><span class="token macro property">#<span class="token directive keyword">include</span><span class="token string">&lt;string.h></span></span>
<span class="token macro property">#<span class="token directive keyword">include</span><span class="token string">&lt;stdio.h></span></span>
<span class="token macro property">#<span class="token directive keyword">define</span> ll long long</span>
<span class="token macro property">#<span class="token directive keyword">define</span> MOD 1000000007</span>
<span class="token keyword">struct</span> nobe<span class="token punctuation">{</span> ll a<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
ll n<span class="token punctuation">;</span>
ll sum<span class="token punctuation">;</span>
nobe <span class="token function">mut</span><span class="token punctuation">(</span>nobe x<span class="token punctuation">,</span>nobe y<span class="token punctuation">)</span><span class="token punctuation">{</span>
nobe res<span class="token punctuation">;</span>
<span class="token function">memset</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>a<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token keyword">sizeof</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>a<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">for</span><span class="token punctuation">(</span>ll i<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>i<span class="token operator">&lt;</span><span class="token number">2</span><span class="token punctuation">;</span>i<span class="token operator">++</span><span class="token punctuation">)</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span> <span class="token keyword">int</span> j<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>j<span class="token operator">&lt;</span><span class="token number">2</span><span class="token punctuation">;</span>j<span class="token operator">++</span><span class="token punctuation">)</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span> <span class="token keyword">int</span> k<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>k<span class="token operator">&lt;</span><span class="token number">2</span><span class="token punctuation">;</span>k<span class="token operator">++</span><span class="token punctuation">)</span>
      res<span class="token punctuation">.</span>a<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token operator">=</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>a<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token operator">+</span>x<span class="token punctuation">.</span>a<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">[</span>k<span class="token punctuation">]</span><span class="token operator">*</span>y<span class="token punctuation">.</span>a<span class="token punctuation">[</span>k<span class="token punctuation">]</span><span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">%</span>MOD<span class="token punctuation">;</span>
<span class="token keyword">return</span> res<span class="token punctuation">;</span><span class="token punctuation">}</span>
<span class="token keyword">void</span> <span class="token function">quick</span><span class="token punctuation">(</span>ll n<span class="token punctuation">)</span><span class="token punctuation">{</span>
      nobe c<span class="token punctuation">,</span>res<span class="token punctuation">;</span>
        c<span class="token punctuation">.</span>a<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>
        c<span class="token punctuation">.</span>a<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>
        c<span class="token punctuation">.</span>a<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>
        c<span class="token punctuation">.</span>a<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
          <span class="token function">memset</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>a<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token keyword">sizeof</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>a<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>i<span class="token operator">&lt;</span><span class="token number">2</span><span class="token punctuation">;</span>i<span class="token operator">++</span><span class="token punctuation">)</span>
                res<span class="token punctuation">.</span>a<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>
            <span class="token keyword">while</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span>
          <span class="token punctuation">{</span>  cont<span class="token operator">++</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>n<span class="token operator">&amp;</span><span class="token number">1</span><span class="token punctuation">)</span>res<span class="token operator">=</span><span class="token function">mut</span><span class="token punctuation">(</span>res<span class="token punctuation">,</span>c<span class="token punctuation">)</span><span class="token punctuation">;</span>
                      c<span class="token operator">=</span><span class="token function">mut</span><span class="token punctuation">(</span>c<span class="token punctuation">,</span>c<span class="token punctuation">)</span><span class="token punctuation">;</span>
            n<span class="token operator">=</span>n<span class="token operator">>></span><span class="token number">1</span><span class="token punctuation">;</span>    <span class="token punctuation">}</span>
<span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%ld\n"</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>a<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token operator">%</span>MOD<span class="token punctuation">)</span><span class="token operator">*</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>a<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token operator">%</span>MOD<span class="token operator">+</span>res<span class="token punctuation">.</span>a<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token operator">%</span>MOD<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token operator">%</span>MOD<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token keyword">while</span><span class="token punctuation">(</span><span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%ld"</span><span class="token punctuation">,</span><span class="token operator">&amp;</span>n<span class="token punctuation">)</span><span class="token operator">!=</span><span class="token constant">EOF</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>     <span class="token function">quick</span><span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

<span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span><span class="token punctuation">}</span>
</code></pre>

            </div>
            <hr/>

            
            <style>
    #reward {
        margin: 40px 0;
        text-align: center;
		z-index: 1000;
		position: float;
		
    }

    #reward .reward-link {
        font-size: 1.88rem;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
	
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
	
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
	
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff;
        background-color: #22AB38;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff;
        background-color: #019FE8;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a class="reward-link btn-floating btn-large waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close"><i class="fa fa-close"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs">
                        <li class="tab wechat-tab waves-effect waves-light"><a class="active" href="#wechat">微信</a></li>
                        <li class="tab alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                    </ul>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('#reward .reward-link').on('click', function () {
            $('#rewardModal').openModal();
        });

        $('#rewardModal .close').on('click', function () {
            $('#rewardModal').closeModal();
        });
    });
</script>
            

            <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    <div class="social-share" data-disabled="qzone" data-wechat-qrcode-helper="<p>微信里点“发现”->“扫一扫”二维码便可查看分享。</p>"></div>
    
</div>

<script src="/libs/share/js/social-share.min.js"></script>

            <div class="reprint">
                <p>
                    <span class="reprint-tip">转载请注明: </span>
                    <a href="https://five-great.coding.me" class="b-link-green">Five-great的博客</a>
                    <i class="fa fa-angle-right fa-lg fa-fw text-color"></i>
                    <a href="/friend-fei-bo-na-qi.html" class="b-link-green">friend-斐波那契</a>
                </p>
            </div>
        </div>
    </div>

	
	    
        

<link rel="stylesheet" href="/libs/gitment/gitment-default.css">
<link rel="stylesheet" href="/css/gitment.css">
 <div class="gitment-card card" data-aos="fade-up">
   
    <div></div>
<!-- 来必力City版安装代码 -->
<div id="lv-container" data-id="city" data-uid="MTAyMC80MDE5NS8xNjcyMg==">
	
	
	<script type="text/javascript">
   (function(d, s) {
       var j, e = d.getElementsByTagName(s)[0];

       if (typeof LivereTower === 'function') { return; }

       j = d.createElement(s);
       j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
       j.async = true;

       e.parentNode.insertBefore(j, e);
   })(document, 'script');
	</script>
<noscript> 为正常使用来必力评论功能请激活JavaScript</noscript>
</div>
<!-- City版安装代码已完成 -->

  </div>
        
    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">上一篇</div>
            <div class="card">
                <a href="/zhu-ti-shuo-ming.html">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/7.jpg" class="responsive-img" alt="主题说明">
                        
                        <span class="card-title">主题说明</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary">hexo-theme-matery      
English Document | 演示示例

这是一个采用Material Design和响应式设计的 Hexo 博客主题。

特性
简单漂亮，文章内容美观易读
Material Desi</div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="fa fa-clock-o fa-fw icon-date"></i>2018-10-20
                        </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/前端/" class="post-category" target="_blank">
                                    前端
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/Hexo/" target="_blank">
                        <span class="chip bg-color">Hexo</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">下一篇</div>
            <div class="card">
                <a href="/da-qiao.html">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/8.jpg" class="responsive-img" alt="搭桥">
                        
                        <span class="card-title">搭桥</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary">题目：搭桥题目链接：http://codevs.cn/problem/1002/题目描述 Description有一矩形区域的城市中建筑了若干建筑物，如果某两个单元格有一个点相联系，则它们属于同一座建筑物。现在想在这些建筑物之间搭建一些桥梁</div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="fa fa-clock-o fa-fw icon-date"></i>2018-09-29
                            </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-user fa-fw"></i>
                            LHL
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/ACM/" target="_blank">
                        <span class="chip bg-color">ACM</span>
                    </a>
                    
                    <a href="/tags/搜索/" target="_blank">
                        <span class="chip bg-color">搜索</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>
</div>
                 

</main>


   <footer class="page-footer bg-color">

	<div>
	    <li class="col s12 m8 l8 copy-right">
	 友链：
	      <a href="https://blog.csdn.net/qq_41923622" target="_blank"><i class="fa fa-link fa-lg"></i> Five-菜鸟级  </a> 	
          &nbsp;&nbsp;<a href="https://blinkfox.github.io/" target="_blank"><i class="fa fa-link fa-lg"></i> 闪烁之狐</a>  		
          &nbsp;&nbsp;<a href="http://www.greyking.cn/" target="_blank"><i class="fa fa-link fa-lg"></i> 浩瀚渊海</a>  				  
		<span id="busuanzi_container_site_uv" style="float:right"> 
  恭喜您成为第 <span id="busuanzi_value_site_uv"></span>位访客
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      </span>
      </span>
	  </li>
		
	</div>
	<div class="container row center-align">
        <div class="col s12 m8 10 copy-right">
           本站由&copy;<a href="http://#" target="_blank">LHL</a>基于
            <a href="https://hexo.io/" target="_blank">Hexo</a>与
            <a href="https://github.com/" target="_blank">github</a>搭建.
        </div>
        <div class="col s12 m4 5 social-link">
            <a href="https://github.com/Five-great/Five-great.github.io" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
                <i class="fa fa-github fa-lg"></i>
            </a>
            <a href="https://985540932@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
                <i class="fa fa-envelope fa-lg"></i>
            </a>
            <a href="#!" class="tooltipped" data-tooltip="QQ: 985540932" data-position="top" data-delay="50">
                <i class="fa fa-qq fa-lg"></i>
            </a>
			<a href="#!" class="tooltipped" data-tooltip="微信:qq985540932" data-position="top" data-delay="50">
                <i class="fa  fa-wechat fa-lg"></i>
            </a>
        </div>
    </div>
</footer>
<div class="progress-bar"></div>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?d62256055258ddb12716821c285aadab";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
           


<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>



<!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title">搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input" autofocus="">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
</script>
<!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fa fa-angle-double-up"></i>
    </a>
</div>


<script src="/libs/materialize/js/materialize.min.js"></script>
<script src="/libs/masonry/masonry.pkgd.min.js"></script>
<script src="/libs/aos/aos.js"></script>
<script src="/libs/scrollprogress/scrollProgress.min.js"></script>
<script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
<script src="/js/matery.js"></script>
</body>
</html>